package com.heima.admin.controller.v1;

import com.heima.admin.service.SensitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理", tags = "敏感词管理", description = "敏感词管理API")
public class SensitiveController {

    @Autowired
    private SensitiveService sensitiveService;

    @PostMapping("/list")
    @ApiOperation(value = "敏感词查询")
    public ResponseResult list(@RequestBody SensitiveDTO dto){
        return sensitiveService.findListByQuery(dto);
    }
    @PostMapping("/save")
    @ApiOperation("敏感词添加")
    public ResponseResult save(@RequestBody AdSensitive adSensitive){
        return sensitiveService.insert(adSensitive);
    }

    @PostMapping("/update")
    @ApiOperation("敏感词修改")
    public ResponseResult update(@RequestBody AdSensitive adSensitive){
        return sensitiveService.update(adSensitive);
    }
    @DeleteMapping("/del/{id}")
    @ApiOperation("敏感词删除")
    public ResponseResult delete(@PathVariable("id") Integer id){
        return sensitiveService.delete(id);
    }

    @PostMapping("/sensitives")
    @ApiOperation("查询敏感词内容列表")
    public ResponseResult<List<String>> sensitives(){
        return sensitiveService.selectAllSensitives();
    }
}
